package com.manpower.ui;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 此类为所有Activity的基类，都继承此类，以便以后添加全局性的功能 就在此设置
 * 
 * @author kechanghe
 * 
 */
public class BaseActivity extends Activity {

	public TextView txtTitle; 
	public ImageView btnBack;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.layout_activity_title);
		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, 
		          R.layout.layout_activity_title);
		View viewOne = LayoutInflater.from(this).inflate(
				R.layout.layout_activity_title, null);
		txtTitle = (TextView)(getWindow().getDecorView().findViewById(R.id.txtTitle));
		
		btnBack = (ImageView)this.findViewById(R.id.btnBack);
		btnBack.setOnClickListener(onClickBack);
	}
	
	public OnClickListener onClickBack = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			BaseActivity.this.finish();
		}
	};

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.menu_base_navigation, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		return super.onOptionsItemSelected(item);
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		return super.onKeyDown(keyCode, event);
	}
	
}
